using UnityEngine;
using System.Collections;

public class Activador : MonoBehaviour
{

    public ActionConstants.Action accion = ActionConstants.Action.ACTION_PUSH;
    public float powerTime = 2;              // tiempo para que se active el poder
    public float efectTime = 10;              // tiempo que esta el efecto de fuego activado

    IEnumerator OnTriggerEnter(Collider hit)
    {
        Debug.Log("SIENTES UN GRAN PODER!");
        if (hit.gameObject.tag == StringConstants.TAG_PLAYER)
        {
            yield return new WaitForSeconds(powerTime);

            PlayerControl player = hit.gameObject.transform.GetComponent<PlayerControl>();
            player.actionsControl.UnlockAction(accion);

            this.transform.FindChild("Fire1").gameObject.SetActive(true);
        }
    }

    IEnumerator OnTriggerExit(Collider hit)
    {
        if (hit.gameObject.tag == StringConstants.TAG_PLAYER)
        {
            yield return new WaitForSeconds(efectTime);
            this.transform.FindChild("Fire1").gameObject.SetActive(false);
        }
    }

}
